import QtQuick 1.1
import com.nokia.meego 1.0

Page {
    id: pageTemplate
    anchors.fill: parent

    Rectangle {
        id: backgroundColor
        anchors.fill: parent
        color: theme.inverted ? "#000000" : "#ffffff"
    }

    Component.onCompleted: {
        console.log('PageTemplate.onCompleted');
    }
    Component.onDestruction: {
        console.log('PageTemplate.onDestruction');
    }

    onVisibleChanged: {
        if (!visible) {
            var stillInStack = appWindow.pageStackContains(pageTemplate)
            var doDestroyPage = !stillInStack && pageTemplate != appWindow.editor;
            console.log("PageTemplate.onVisibleChanged hidden page=" + pageTemplate + ' stillInStack=' + stillInStack + ' doDestroyPage=' + doDestroyPage);
            if (doDestroyPage) {
                //if (pageTemplate == appWindow.editor) throw 'The EditorPage should never be destroyed by this function';

                pageTemplate.destroy();
            }
        }
    }
}
